<?php
/**
 * Created by PhpStorm.
 * User: win7
 * Date: 2018/4/27
 * Time: 14:03
 */
namespace app\lib\exception;

use think\Exception;

class BaseException extends Exception
{
    // HTTP 状态码 404 200
    public $code = 400;

    // 错误具体信息
    public $msg = '参数错误';

    // 自定义的错误码
    public $errorCode = 10000;

    public function __construct($param = []) {
        // 参数必须是数组
        if (!is_array($param)) {
            return ;
//            throw new Exception('参数必须是正整数');
        }

        if (array_key_exists('code', $param)) {
            $this->code = $param['code'];
        }
        if (array_key_exists('msg', $param)) {
            $this->msg = $param['msg'];
        }
        if (array_key_exists('errorCode', $param)) {
            $this->errorCode = $param['errorCode'];
        }
    }
}